package ooday03;

public class Test {
    public static void main(String[] args) {




















        /*Master master=new Master();
        Dog dog = new Dog("小小",6,"黄色");
        Fish fish = new Fish("鱼鱼",1,"红色");
        Chick chick = new Chick("花花",2,"白色");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);
        */





























       /* Chick hh = new Chick("花花",2,"白色");
        hh.drink();
        hh.eat();
        hh.layEgg();
        Chick[] chicks=new Chick[3];
        chicks[0]=new Chick("小花",1,"花色");
        chicks[1]=new Chick("小彩",2,"彩色");
        chicks[2]=new Chick("小绿",3,"绿色");
        for (int i = 0; i < chicks.length; i++) {
            chicks[i].eat();
            chicks[i].drink();

        }


        Dog xx = new Dog("小小",6,"黄色");
        xx.drink();
        xx.eat();
        xx.lookHome();
        xx.swim();

        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("小黄",4,"黄色");
        dogs[1]=new Dog("小白",5,"白色");
        dogs[2]=new Dog("小黑",6,"黑色");

        dogs[2].age=9;
        dogs[2].swim();
        for (int i = 0; i < dogs.length; i++) {
            dogs[i].eat();
            dogs[i].drink();
        }


        Fish yy = new Fish("鱼鱼",1,"红色");
        yy.drink();
        yy.eat();
        yy.swim();
        Fish[] fish = new Fish[3];
        fish[0]=new Fish("小金",7,"金色");
        fish[1]=new Fish("小红",8,"红色");
        fish[2]=new Fish("小蓝",9,"蓝色");
        for (int i = 0; i < fish.length; i++) {
            fish[i].eat();
            fish[i].drink();
        }*/

        Animal[] animals = new Animal[9];
        animals[0]=new Dog("xa",4,"a");
        animals[1]=new Dog("小白",5,"白色");
        animals[2]=new Dog("小黑",6,"黑色");
        animals[3]=new Chick("小花",1,"花色");
        animals[4]=new Chick("小彩",2,"彩色");
        animals[5]=new Chick("小绿",3,"绿色");
        animals[6]=new Fish("小金",7,"金色");
        animals[7]=new Fish("小红",8,"红色");
        animals[8]=new Fish("小蓝",9,"蓝色");

        for (int i = 0; i < animals.length; i++) {
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog) {
                Dog dog = (Dog) animals[i];
                dog.swim();
                dog.lookHome();
            }
            if (animals[i] instanceof Chick){
                Chick chick=(Chick) animals[i];
                chick.layEgg();
            }
            if (animals[i] instanceof Fish){
                Fish fish=(Fish) animals[i];
                fish.swim();
            }
            if (animals[i] instanceof Swim){
                Swim s = (Swim) animals[i];
            }
        }
    }
}
